<template>
<div class="todo-header">
  <input type="text" placeholder="请输入任务名称，按回车确认" @keyup.enter="add">
</div>
</template>

<script>
import {nanoid} from "nanoid";

export default {
  name: "MyHeader",
  methods:{
    add(event){
      //输入包装成对象
      const todo = {id:nanoid(),title:event.target.value,done:false}
      this.$emit('addTodo',todo)
    },

  },


}
</script>

<style scoped>

.todo-header input{
  width: 560px;
  height: 28px;
  font-size: 14px;
  border: 1px solid darkgray;
  border-radius: 4px;
  padding: 4px 7px;
}
.todo-header input:focus{
  outline: none;
  border-color: cadetblue;
  box-shadow: inset 0 1px 1px darkblue,0 0 8px darkblue;
}
</style>
